package model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;



public class Deltager {
	private String navn;
	private Status status; //"godtatt", "forkastet" eller "ikkeSvart"
	
	private final static String STATUS_FORANDRET = "status_forandret";
	
	private PropertyChangeSupport pcs;
	
	public Deltager() {		
		pcs = new PropertyChangeSupport(this);

	}
	
	public Deltager(String navn, Status status){	
		this.navn = navn;
		this.status = status;
		pcs = new PropertyChangeSupport(this);

	}
	
	public String getNavn() {
		return navn;
	}
	public void setNavn(String navn) {
		this.navn = navn;
	}
	public Status getStatus() {
		return status;
	}
	public void setStatus(Status status) {
		
		Status temp = this.status;
		this.status = status;
		
		pcs.firePropertyChange(STATUS_FORANDRET, temp, this.status);
		
	}
	
	public boolean equals(Object obj){
		if (!(obj instanceof Deltager)){
			return false;
		}
		Deltager deltager = (Deltager)obj;
		return 	navn.equals(deltager.getNavn()) &&
				status == deltager.getStatus();
	}
	
	public void addPropertyChangeListener(PropertyChangeListener listener) {
		pcs.addPropertyChangeListener(listener);
	}

}
